package br.com.edoc.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TratamentoString {
	public static final String removeEspacamentoDuplo(String valor){
	    String padrao = "\\s{2,}";
	    Pattern regPat = Pattern.compile(padrao);	     
	    Matcher matcher = regPat.matcher(valor);	    
	    return matcher.replaceAll(" ").trim();
	}
	public static final String removeEspacamentoDuploDeixaCaixaAlta(String valor){
	    String padrao = "\\s{2,}";
	    Pattern regPat = Pattern.compile(padrao);	     
	    Matcher matcher = regPat.matcher(valor);	    
	    return matcher.replaceAll(" ").trim().toUpperCase();
	}
	
	public static final boolean isValidoEmail(String email){
		Pattern pattern = Pattern.compile("[a-z_][a-z0-9._]+@.+\\.[a-z]+");
		Matcher matcher = pattern.matcher(email);
		if(matcher.matches()){
			return true;
		}
		else {
			return false;
		}
	}
}
